/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tabelaprice;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
 * @author Yanni 
 */
public class TabelaPrice extends MIDlet implements CommandListener {

    private boolean midletPaused = false;
    //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private Form formInicial;
    private TextField txtMeses;
    private TextField txtEmpréstimo;
    private TextField txtJuros;
    private List list;
    private Form formAjuda;
    private StringItem oQueStringItem;
    private ImageItem imageItem;
    private Form formSobre;
    private StringItem sobre1StringItem;
    private StringItem sobre2StringItem;
    private Command calcularCommand;
    private Command exitCommand;
    private Command backCommand;
    private Command limparCommand;
    private Command backCommand1;
    private Command ajudaCommand;
    private Command backCommand2;
    private Command backCommand3;
    private Command SobreCommand;
    private Image setaImagem;
    private Image cifrãoImagem;
    private Image tabelaImagem;
    //</editor-fold>//GEN-END:|fields|0|

    /**
     * The TabelaPrice constructor.
     */
    public TabelaPrice() {
    }

    /**
     * Método para limpar o conteúdo das caixas de texto e a lista
     */
    private void limpar() {
        //se o formInicial estiver sendo exibido, apagará somente os campos desse form
        //senão apagará a lista também
        if(formInicial.isShown())
        {
            txtEmpréstimo.setString("");
            txtJuros.setString("");
            txtMeses.setString("");
        }
        else
        {//deleta todo o conteúdo da lista
            list.deleteAll();
        }
    }

    /**
     * @param b: o número base
     * @param e: é o expoente
     * @return Retorna o valor do primeiro argumento elevado a potência do segundo argumento.
     */
    public static double potência(double b, double e) {
        double pot = 1;

        for (int cont = 1; cont <= Math.abs(e); cont++) {
            pot *= b;
        }

        if (e < 0) {
            pot = 1 / pot;
        }
        return pot;
    }

    /**
     * @param valor: valor a ser formatado
     * @return o valor no formato de moeda (R$).
     */
    public static String formatação(double valor) {
        double n = valor;
        int n1 = (int) n;
        int n2 = (int) ((n - n1) * 100);
        String saída = "R$ " + n1 + "," + n2;
        
        return saída;
    }

    //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
    //</editor-fold>//GEN-END:|methods|0|
    //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
    /**
     * Initilizes the application.
     * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
     */
    private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
        // write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
        // write post-initialize user code here
    }//GEN-BEGIN:|0-initialize|2|
    //</editor-fold>//GEN-END:|0-initialize|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Started point.
     */
    public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
        // write pre-action user code here
        switchDisplayable(null, getFormInicial());//GEN-LINE:|3-startMIDlet|1|3-postAction
        // write post-action user code here
    }//GEN-BEGIN:|3-startMIDlet|2|
    //</editor-fold>//GEN-END:|3-startMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
    /**
     * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
     */
    public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
        // write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
        // write post-action user code here
    }//GEN-BEGIN:|4-resumeMIDlet|2|
    //</editor-fold>//GEN-END:|4-resumeMIDlet|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
    /**
     * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
     * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
     * @param nextDisplayable the Displayable to be set
     */
    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
        // write pre-switch user code here
        Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
        if (alert == null) {
            display.setCurrent(nextDisplayable);
        } else {
            display.setCurrent(alert, nextDisplayable);
        }//GEN-END:|5-switchDisplayable|1|5-postSwitch
        // write post-switch user code here
    }//GEN-BEGIN:|5-switchDisplayable|2|
    //</editor-fold>//GEN-END:|5-switchDisplayable|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
    /**
     * Called by a system to indicated that a command has been invoked on a particular displayable.
     * @param command the Command that was invoked
     * @param displayable the Displayable where the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
        // write pre-action user code here
        if (displayable == formAjuda) {//GEN-BEGIN:|7-commandAction|1|76-preAction
            if (command == SobreCommand) {//GEN-END:|7-commandAction|1|76-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormSobre());//GEN-LINE:|7-commandAction|2|76-postAction
                // write post-action user code here
            } else if (command == backCommand2) {//GEN-LINE:|7-commandAction|3|63-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormInicial());//GEN-LINE:|7-commandAction|4|63-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|5|60-preAction
        } else if (displayable == formInicial) {
            if (command == ajudaCommand) {//GEN-END:|7-commandAction|5|60-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormAjuda());//GEN-LINE:|7-commandAction|6|60-postAction
                // write post-action user code here
            } else if (command == calcularCommand) {//GEN-LINE:|7-commandAction|7|18-preAction
                //declaração das variáveis
                double saldoDevedor = 0;
                int meses = 0;
                double juros = 0;
                double prestação;
                double amortização;
                double juros2;
                double saldo2;
                int c = 0;
                boolean erro = false;

                //se nenhum erro ocorrer, os valores das caixas de textos serão atribuídos as variáveis
                try {
                    saldoDevedor = Double.parseDouble(txtEmpréstimo.getString());
                    meses = Integer.parseInt(txtMeses.getString());
                    juros = Double.parseDouble(txtJuros.getString());

                    if ((saldoDevedor <= 0) || (meses <= 0) || (juros <= 0)) {
                        Alert mensagem = new Alert("Erro");
                        mensagem.setString("Digite somente valores positivos.");
                        mensagem.setTimeout(3000);
                        getDisplay().setCurrent(mensagem);

                        limpar();
                        erro = true;
                    }
                }
                catch (NumberFormatException e) { //se acontecer algum erro, aparecerá um Alert avisando
                    Alert mensagem = new Alert("Erro");
                    mensagem.setString("Digite os valores corretamente.");
                    mensagem.setTimeout(3000);
                    getDisplay().setCurrent(mensagem);

                    limpar();
                    erro = true;
                }

                if (!erro)
                {//se nenhum erro aconteceu, será exibida a lista e o cálculo será feito
                    switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|8|18-postAction

                    //cálculo da prestação
                    prestação = saldoDevedor * (juros / 100) / (1 - (potência(1 + (juros / 100), -meses)));

                    //mostrando o valor da parcela na lista
                    list.append("Valor da parcela: " + formatação(prestação) + "\n", getCifrãoImagem());

                    //cálculo da amortização
                    while (meses > 0) {
                        juros2 = saldoDevedor * (juros / 100);
                        saldo2 = saldoDevedor + juros2;
                        saldoDevedor = saldo2 - prestação;
                        amortização = prestação - juros2;
                        meses--;
                        c++;

                        if (saldoDevedor < 0) {
                            saldoDevedor = 0;
                        }
                         //mostrando os valores de juros, amortização e saldo devedor na lista
                        list.append(c + "º mês\n  Juros: " + formatação(juros2) + " \n  Amortização: " + formatação(amortização) + "\n  Saldo:" + formatação(saldoDevedor) + "\n", getSetaImagem());
                    }
                }//fim do if de verificação de erro

            } else if (command == exitCommand) {//GEN-LINE:|7-commandAction|9|20-preAction
                // write pre-action user code here
                exitMIDlet();//GEN-LINE:|7-commandAction|10|20-postAction
                // write post-action user code here
            } else if (command == limparCommand) {//GEN-LINE:|7-commandAction|11|33-preAction
                limpar();
//GEN-LINE:|7-commandAction|12|33-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|13|71-preAction
        } else if (displayable == formSobre) {
            if (command == backCommand3) {//GEN-END:|7-commandAction|13|71-preAction
                // write pre-action user code here
                switchDisplayable(null, getFormInicial());//GEN-LINE:|7-commandAction|14|71-postAction
                // write post-action user code here
            }//GEN-BEGIN:|7-commandAction|15|37-preAction
        } else if (displayable == list) {
            if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|15|37-preAction
                // write pre-action user code here
                listAction();//GEN-LINE:|7-commandAction|16|37-postAction
                // write post-action user code here
            } else if (command == backCommand1) {//GEN-LINE:|7-commandAction|17|41-preAction

                switchDisplayable(null, getFormInicial());//GEN-LINE:|7-commandAction|18|41-postAction
                limpar();
            }//GEN-BEGIN:|7-commandAction|19|7-postCommandAction
        }//GEN-END:|7-commandAction|19|7-postCommandAction
        // write post-action user code here
    }//GEN-BEGIN:|7-commandAction|20|
    //</editor-fold>//GEN-END:|7-commandAction|20|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: formInicial ">//GEN-BEGIN:|14-getter|0|14-preInit
    /**
     * Returns an initiliazed instance of formInicial component.
     * @return the initialized component instance
     */
    public Form getFormInicial() {
        if (formInicial == null) {//GEN-END:|14-getter|0|14-preInit
            // write pre-init user code here
            formInicial = new Form("Tabela Price", new Item[] { getTxtEmpréstimo(), getTxtMeses(), getTxtJuros() });//GEN-BEGIN:|14-getter|1|14-postInit
            formInicial.addCommand(getCalcularCommand());
            formInicial.addCommand(getLimparCommand());
            formInicial.addCommand(getAjudaCommand());
            formInicial.addCommand(getExitCommand());
            formInicial.setCommandListener(this);//GEN-END:|14-getter|1|14-postInit
            // write post-init user code here
        }//GEN-BEGIN:|14-getter|2|
        return formInicial;
    }
    //</editor-fold>//GEN-END:|14-getter|2|

    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: calcularCommand ">//GEN-BEGIN:|17-getter|0|17-preInit
    /**
     * Returns an initiliazed instance of calcularCommand component.
     * @return the initialized component instance
     */
    public Command getCalcularCommand() {
        if (calcularCommand == null) {//GEN-END:|17-getter|0|17-preInit
            // write pre-init user code here
            calcularCommand = new Command("Calcular", Command.OK, 0);//GEN-LINE:|17-getter|1|17-postInit
            // write post-init user code here
        }//GEN-BEGIN:|17-getter|2|
        return calcularCommand;
    }
    //</editor-fold>//GEN-END:|17-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">//GEN-BEGIN:|19-getter|0|19-preInit
    /**
     * Returns an initiliazed instance of exitCommand component.
     * @return the initialized component instance
     */
    public Command getExitCommand() {
        if (exitCommand == null) {//GEN-END:|19-getter|0|19-preInit
            // write pre-init user code here
            exitCommand = new Command("Sair", Command.EXIT, 0);//GEN-LINE:|19-getter|1|19-postInit
            // write post-init user code here
        }//GEN-BEGIN:|19-getter|2|
        return exitCommand;
    }
    //</editor-fold>//GEN-END:|19-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand ">//GEN-BEGIN:|21-getter|0|21-preInit
    /**
     * Returns an initiliazed instance of backCommand component.
     * @return the initialized component instance
     */
    public Command getBackCommand() {
        if (backCommand == null) {//GEN-END:|21-getter|0|21-preInit
            // write pre-init user code here
            backCommand = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|21-getter|1|21-postInit
            // write post-init user code here
        }//GEN-BEGIN:|21-getter|2|
        return backCommand;
    }
    //</editor-fold>//GEN-END:|21-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: txtEmpréstimo ">//GEN-BEGIN:|26-getter|0|26-preInit
    /**
     * Returns an initiliazed instance of txtEmpréstimo component.
     * @return the initialized component instance
     */
    public TextField getTxtEmpréstimo() {
        if (txtEmpréstimo == null) {//GEN-END:|26-getter|0|26-preInit
            // write pre-init user code here
            txtEmpréstimo = new TextField("Valor do empr\u00E9stimo:", "", 32, TextField.DECIMAL);//GEN-LINE:|26-getter|1|26-postInit
            // write post-init user code here
        }//GEN-BEGIN:|26-getter|2|
        return txtEmpréstimo;
    }
    //</editor-fold>//GEN-END:|26-getter|2|
    //</editor-fold>
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: txtMeses ">//GEN-BEGIN:|27-getter|0|27-preInit
    /**
     * Returns an initiliazed instance of txtMeses component.
     * @return the initialized component instance
     */
    public TextField getTxtMeses() {
        if (txtMeses == null) {//GEN-END:|27-getter|0|27-preInit
            // write pre-init user code here
            txtMeses = new TextField("N\u00FAmero de presta\u00E7\u00F5es (em meses):", "", 32, TextField.NUMERIC);//GEN-LINE:|27-getter|1|27-postInit
            // write post-init user code here
        }//GEN-BEGIN:|27-getter|2|
        return txtMeses;
    }
    //</editor-fold>//GEN-END:|27-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: txtJuros ">//GEN-BEGIN:|28-getter|0|28-preInit
    /**
     * Returns an initiliazed instance of txtJuros component.
     * @return the initialized component instance
     */
    public TextField getTxtJuros() {
        if (txtJuros == null) {//GEN-END:|28-getter|0|28-preInit
            // write pre-init user code here
            txtJuros = new TextField("Taxa de juros (% a.m.):", "", 32, TextField.DECIMAL);//GEN-LINE:|28-getter|1|28-postInit
            // write post-init user code here
        }//GEN-BEGIN:|28-getter|2|
        return txtJuros;
    }
    //</editor-fold>//GEN-END:|28-getter|2|
    //</editor-fold>
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: limparCommand ">//GEN-BEGIN:|32-getter|0|32-preInit
    /**
     * Returns an initiliazed instance of limparCommand component.
     * @return the initialized component instance
     */
    public Command getLimparCommand() {
        if (limparCommand == null) {//GEN-END:|32-getter|0|32-preInit
            // write pre-init user code here
            limparCommand = new Command("Limpar campos", Command.OK, 0);//GEN-LINE:|32-getter|1|32-postInit
            // write post-init user code here
        }//GEN-BEGIN:|32-getter|2|
        return limparCommand;
    }
    //</editor-fold>//GEN-END:|32-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: list ">//GEN-BEGIN:|35-getter|0|35-preInit
    /**
     * Returns an initiliazed instance of list component.
     * @return the initialized component instance
     */
    public List getList() {
        if (list == null) {//GEN-END:|35-getter|0|35-preInit
            // write pre-init user code here
            list = new List("Tabela Price", Choice.IMPLICIT);//GEN-BEGIN:|35-getter|1|35-postInit
            list.addCommand(getBackCommand1());
            list.setCommandListener(this);
            list.setSelectedFlags(new boolean[] {  });//GEN-END:|35-getter|1|35-postInit
            // write post-init user code here
        }//GEN-BEGIN:|35-getter|2|
        return list;
    }
    //</editor-fold>//GEN-END:|35-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Method: listAction ">//GEN-BEGIN:|35-action|0|35-preAction
    /**
     * Performs an action assigned to the selected list element in the list component.
     */
    public void listAction() {//GEN-END:|35-action|0|35-preAction
        // enter pre-action user code here
        String __selectedString = getList().getString(getList().getSelectedIndex());//GEN-LINE:|35-action|1|35-postAction
        // enter post-action user code here
    }//GEN-BEGIN:|35-action|2|
    //</editor-fold>//GEN-END:|35-action|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand1 ">//GEN-BEGIN:|40-getter|0|40-preInit
    /**
     * Returns an initiliazed instance of backCommand1 component.
     * @return the initialized component instance
     */
    public Command getBackCommand1() {
        if (backCommand1 == null) {//GEN-END:|40-getter|0|40-preInit
            // write pre-init user code here
            backCommand1 = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|40-getter|1|40-postInit
            // write post-init user code here
        }//GEN-BEGIN:|40-getter|2|
        return backCommand1;
    }
    //</editor-fold>//GEN-END:|40-getter|2|


    //</editor-fold>
    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: setaImagem ">//GEN-BEGIN:|48-getter|0|48-preInit
    /**
     * Returns an initiliazed instance of setaImagem component.
     * @return the initialized component instance
     */
    public Image getSetaImagem() {
        if (setaImagem == null) {//GEN-END:|48-getter|0|48-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|48-getter|1|48-@java.io.IOException
                setaImagem = Image.createImage("/img/Setinha.png");
            } catch (java.io.IOException e) {//GEN-END:|48-getter|1|48-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|48-getter|2|48-postInit
            // write post-init user code here
        }//GEN-BEGIN:|48-getter|3|
        return setaImagem;
    }
    //</editor-fold>//GEN-END:|48-getter|3|
    //</editor-fold>
    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cifrãoImagem ">//GEN-BEGIN:|57-getter|0|57-preInit
    /**
     * Returns an initiliazed instance of cifrãoImagem component.
     * @return the initialized component instance
     */
    public Image getCifrãoImagem() {
        if (cifrãoImagem == null) {//GEN-END:|57-getter|0|57-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|57-getter|1|57-@java.io.IOException
                cifrãoImagem = Image.createImage("/img/2xdim.png");
            } catch (java.io.IOException e) {//GEN-END:|57-getter|1|57-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|57-getter|2|57-postInit
            // write post-init user code here
        }//GEN-BEGIN:|57-getter|3|
        return cifrãoImagem;
    }
    //</editor-fold>//GEN-END:|57-getter|3|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: formAjuda ">//GEN-BEGIN:|58-getter|0|58-preInit
    /**
     * Returns an initiliazed instance of formAjuda component.
     * @return the initialized component instance
     */
    public Form getFormAjuda() {
        if (formAjuda == null) {//GEN-END:|58-getter|0|58-preInit
            // write pre-init user code here
            formAjuda = new Form("Ajuda", new Item[] { getImageItem(), getOQueStringItem() });//GEN-BEGIN:|58-getter|1|58-postInit
            formAjuda.addCommand(getSobreCommand());
            formAjuda.addCommand(getBackCommand2());
            formAjuda.setCommandListener(this);//GEN-END:|58-getter|1|58-postInit
            // write post-init user code here
        }//GEN-BEGIN:|58-getter|2|
        return formAjuda;
    }
    //</editor-fold>//GEN-END:|58-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: ajudaCommand ">//GEN-BEGIN:|59-getter|0|59-preInit
    /**
     * Returns an initiliazed instance of ajudaCommand component.
     * @return the initialized component instance
     */
    public Command getAjudaCommand() {
        if (ajudaCommand == null) {//GEN-END:|59-getter|0|59-preInit
            // write pre-init user code here
            ajudaCommand = new Command("Ajuda", Command.OK, 0);//GEN-LINE:|59-getter|1|59-postInit
            // write post-init user code here
        }//GEN-BEGIN:|59-getter|2|
        return ajudaCommand;
    }
    //</editor-fold>//GEN-END:|59-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand2 ">//GEN-BEGIN:|62-getter|0|62-preInit
    /**
     * Returns an initiliazed instance of backCommand2 component.
     * @return the initialized component instance
     */
    public Command getBackCommand2() {
        if (backCommand2 == null) {//GEN-END:|62-getter|0|62-preInit
            // write pre-init user code here
            backCommand2 = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|62-getter|1|62-postInit
            // write post-init user code here
        }//GEN-BEGIN:|62-getter|2|
        return backCommand2;
    }
    //</editor-fold>//GEN-END:|62-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: imageItem ">//GEN-BEGIN:|65-getter|0|65-preInit
    /**
     * Returns an initiliazed instance of imageItem component.
     * @return the initialized component instance
     */
    public ImageItem getImageItem() {
        if (imageItem == null) {//GEN-END:|65-getter|0|65-preInit
            // write pre-init user code here
            imageItem = new ImageItem("", getTabelaImagem(), ImageItem.LAYOUT_CENTER | Item.LAYOUT_TOP | Item.LAYOUT_BOTTOM | Item.LAYOUT_VCENTER | ImageItem.LAYOUT_NEWLINE_AFTER, "<Imagem perdida>");//GEN-LINE:|65-getter|1|65-postInit
            // write post-init user code here
        }//GEN-BEGIN:|65-getter|2|
        return imageItem;
    }
    //</editor-fold>//GEN-END:|65-getter|2|
    //</editor-fold>
    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: tabelaImagem ">//GEN-BEGIN:|66-getter|0|66-preInit
    /**
     * Returns an initiliazed instance of tabelaImagem component.
     * @return the initialized component instance
     */
    public Image getTabelaImagem() {
        if (tabelaImagem == null) {//GEN-END:|66-getter|0|66-preInit
            // write pre-init user code here
            try {//GEN-BEGIN:|66-getter|1|66-@java.io.IOException
                tabelaImagem = Image.createImage("/img/Tabela price.png");
            } catch (java.io.IOException e) {//GEN-END:|66-getter|1|66-@java.io.IOException
                e.printStackTrace();
            }//GEN-LINE:|66-getter|2|66-postInit
            // write post-init user code here
        }//GEN-BEGIN:|66-getter|3|
        return tabelaImagem;
    }
    //</editor-fold>//GEN-END:|66-getter|3|
    //</editor-fold>
    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: oQueStringItem ">//GEN-BEGIN:|68-getter|0|68-preInit
    /**
     * Returns an initiliazed instance of oQueStringItem component.
     * @return the initialized component instance
     */
    public StringItem getOQueStringItem() {
        if (oQueStringItem == null) {//GEN-END:|68-getter|0|68-preInit
            // write pre-init user code here
            oQueStringItem = new StringItem("O que devo fazer?", "Na tela inicial digite o valor do empr\u00E9stimo (somente valores num\u00E9ricos), o n\u00FAmero de meses e a porcentagem da taxa de juros ao m\u00EAs, depois v\u00E1 em \"Menu\" e escolha \"Calcular\".", Item.PLAIN);//GEN-LINE:|68-getter|1|68-postInit
            // write post-init user code here
        }//GEN-BEGIN:|68-getter|2|
        return oQueStringItem;
    }
    //</editor-fold>//GEN-END:|68-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: formSobre ">//GEN-BEGIN:|69-getter|0|69-preInit
    /**
     * Returns an initiliazed instance of formSobre component.
     * @return the initialized component instance
     */
    public Form getFormSobre() {
        if (formSobre == null) {//GEN-END:|69-getter|0|69-preInit
            // write pre-init user code here
            formSobre = new Form("Sobre", new Item[] { getSobre1StringItem(), getSobre2StringItem() });//GEN-BEGIN:|69-getter|1|69-postInit
            formSobre.addCommand(getBackCommand3());
            formSobre.setCommandListener(this);//GEN-END:|69-getter|1|69-postInit
            // write post-init user code here
        }//GEN-BEGIN:|69-getter|2|
        return formSobre;
    }
    //</editor-fold>//GEN-END:|69-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand3 ">//GEN-BEGIN:|70-getter|0|70-preInit
    /**
     * Returns an initiliazed instance of backCommand3 component.
     * @return the initialized component instance
     */
    public Command getBackCommand3() {
        if (backCommand3 == null) {//GEN-END:|70-getter|0|70-preInit
            // write pre-init user code here
            backCommand3 = new Command("Voltar", Command.BACK, 0);//GEN-LINE:|70-getter|1|70-postInit
            // write post-init user code here
        }//GEN-BEGIN:|70-getter|2|
        return backCommand3;
    }
    //</editor-fold>//GEN-END:|70-getter|2|

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: SobreCommand ">//GEN-BEGIN:|75-getter|0|75-preInit
    /**
     * Returns an initiliazed instance of SobreCommand component.
     * @return the initialized component instance
     */
    public Command getSobreCommand() {
        if (SobreCommand == null) {//GEN-END:|75-getter|0|75-preInit
            // write pre-init user code here
            SobreCommand = new Command("Sobre", Command.OK, 0);//GEN-LINE:|75-getter|1|75-postInit
            // write post-init user code here
        }//GEN-BEGIN:|75-getter|2|
        return SobreCommand;
    }
    //</editor-fold>//GEN-END:|75-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: sobre1StringItem ">//GEN-BEGIN:|79-getter|0|79-preInit
    /**
     * Returns an initiliazed instance of sobre1StringItem component.
     * @return the initialized component instance
     */
    public StringItem getSobre1StringItem() {
        if (sobre1StringItem == null) {//GEN-END:|79-getter|0|79-preInit
            // write pre-init user code here
            sobre1StringItem = new StringItem("", "A Tabela Price (ou Sistema Franc\u00EAs de Amortiza\u00E7\u00E3o) \u00E9 um m\u00E9todo utilizado na amortiza\u00E7\u00E3o de empr\u00E9stimos ou financiamentos, cuja a principal caracter\u00EDstica \u00E9 possuir parcelas iguais. Usa o regime de juros compostos para calcular o valor das parcelas de um empr\u00E9stimo e, dessa parcela, qual \u00E9 a propor\u00E7\u00E3o relativa aos pagamentos dos juros e a amortiza\u00E7\u00E3o do valor emprestado.");//GEN-LINE:|79-getter|1|79-postInit
            // write post-init user code here
        }//GEN-BEGIN:|79-getter|2|
        return sobre1StringItem;
    }
    //</editor-fold>//GEN-END:|79-getter|2|
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc=" Generated Getter: sobre2StringItem ">//GEN-BEGIN:|80-getter|0|80-preInit
    /**
     * Returns an initiliazed instance of sobre2StringItem component.
     * @return the initialized component instance
     */
    public StringItem getSobre2StringItem() {
        if (sobre2StringItem == null) {//GEN-END:|80-getter|0|80-preInit
            // write pre-init user code here
            sobre2StringItem = new StringItem("", "Amortiza\u00E7\u00E3o \u00E9 um processo de extin\u00E7\u00E3o de uma d\u00EDvida atrav\u00E9s de pagamentos peri\u00F3dicos, que s\u00E3o realizados em fun\u00E7\u00E3o de um planejamento, de modo que cada presta\u00E7\u00E3o corresponde \u00E0 soma do reembolso do capital ou do pagamento dos juros do saldo devedor, podendo ser o reembolso de ambos, sendo que os juros s\u00E3o sempre calculados sobre o saldo devedor.");//GEN-LINE:|80-getter|1|80-postInit
            // write post-init user code here
        }//GEN-BEGIN:|80-getter|2|
        return sobre2StringItem;
    }
    //</editor-fold>//GEN-END:|80-getter|2|
    //</editor-fold>

    /**
     * Returns a display instance.
     * @return the display instance.
     */
    public Display getDisplay() {
        return Display.getDisplay(this);
    }

    /**
     * Exits MIDlet.
     */
    public void exitMIDlet() {
        switchDisplayable(null, null);
        destroyApp(true);
        notifyDestroyed();
    }

    /**
     * Called when MIDlet is started.
     * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
     */
    public void startApp() {
        if (midletPaused) {
            resumeMIDlet();
        } else {
            initialize();
            startMIDlet();
        }
        midletPaused = false;
    }

    /**
     * Called when MIDlet is paused.
     */
    public void pauseApp() {
        midletPaused = true;
    }

    /**
     * Called to signal the MIDlet to terminate.
     * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
     */
    public void destroyApp(boolean unconditional) {
    }
}
